<?php
/**
 * Pert Library
 * Random Password Class
 *
 * @author	Emre Hasegeli <hasegeli@gmail.com>
 * @license	GNU General Public License v3
 */

namespace Pert;

class RandomPassword
{
	const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabchefghjkmnpqrstuvwxyz0123456789';

	const defaultLength = 6;

	private $value;

	public function __Construct($length = self::defaultLength)
	{
		$this->value = '';

		for($i = 0;
				$i < $length;
				$i++)
			$this->value .= substr(self::characters, rand(0, strlen(self::characters) - 1), 1);
	}

	public function __ToString()
	{
		return $this->value;
	}
}
